<template>
    <div id="app">
        <router-view></router-view>
    </div>
</template>

<script>
// import Socket from './websocket.js'
export default {
    name: 'app',
    created() {
        try {
            const Vm = this
            console.log(this.cookie.get('clientId'))
            // this.socket.sendMessage({
            //     interface: 'getAdInfo'
            // })
            // this.shufflingList = window.shufflingList.result
            // let mockList
            // this.shufflingList.map(item => {
            //     let a = {
            //         imgUrl: item.imgUrl
            //     }
            //     mockList.push(a)
            // })
            // this.$store.commit('SET_shufflingList', mockList)
            // console.log('SET_shufflingList', mockList)
            if (this.cookie.get('clientId') === undefined || this.cookie.get('clientId') === '') {
                this.$store.dispatch('getClientInfo')
                    .then(res => {
                        console.log(res)
                        let clientInfo = JSON.parse(res.data.result)
                        Vm.$store.commit('SET_clientInfo', clientInfo)
                        // 保存终端信息到cookie 保存终端信息到cookie
                        this.cookie.set('clientId', clientInfo.uuid)
                        this.cookie.set('clientIp', clientInfo.ip)
                        // 注册打印终端
                        let printerLogin = {
                            interface: 'printerLogin',
                            clientId: clientInfo.uuid,
                            ip: clientInfo.ip,
                            clientType: 1 // 1为电脑端
                        }
                        this.socket.sendMessage(printerLogin)
                    })
                    .catch(error => {
                        console.log(error)
                    })
            } else {
                // 注册打印终端
                let printerLogin = {
                    interface: 'printerLogin',
                    clientId: this.cookie.get('clientId'),
                    ip: this.cookie.get('clientIp'),
                    clientType: 1
                }
                this.socket.sendMessage(printerLogin)
                let tempClientInfo = {
                    uuid: this.cookie.get('clientId'),
                    ip: this.cookie.get('clientIp')
                }
                this.$store.commit('SET_clientInfo', tempClientInfo)
            }
        } catch (error) {
        }
    },
    methods: {
    }
}
</script>
<style lang=less>
@import './style/variable';
body {
    background-color: @background-color;
}
::-webkit-scrollbar{
    display:none;
}
::scrollbar {
    display: none;
}
#app {
    height: 100vh;
    /* max-height: 1880px; */
    background-color: @background-color;
    overflow: hidden;
}
.ivu-modal-content {
    border-radius: 10px;
}
.ivu-modal-body {
    padding: 0 !important;
    /* height: 650px; */
}
.cjc-nav {
    .left-btn {
        color:#ffffff;
    }
    .click-size.size {
        color: white;
        font-size: 22px;
    }
}
</style>
